wpf numeric only textbox

90

wpf numeric only textbox -

<TextBox Name="NumberTextBox" PreviewTextInput="NumberValidationTextBox"/>

-------------------------------------------------------------------------------

using System.Text.RegularExpressions;
private void NumberValidationTextBox(object sender, TextCompositionEventArgs e)
{
    Regex regex = new Regex("[^0-9]+");
    e.Handled = regex.IsMatch(e.Text);
}

Comments

Submit
0 Comments